| Dart.Snmp Namespace > User Class : ProcessOwnUserKeyChange(SetMessage,Byte[]) Method |
Public Sub ProcessOwnUserKeyChange( _ ByVal keyChangeMessage As SetMessage, _ ByVal engineId() As Byte _ )
Dim instance As User Dim keyChangeMessage As SetMessage Dim engineId() As Byte instance.ProcessOwnUserKeyChange(keyChangeMessage, engineId)
public void ProcessOwnUserKeyChange( SetMessage keyChangeMessage, byte[] engineId )
public: void ProcessOwnUserKeyChange( SetMessage* keyChangeMessage, byte[]* engineId )
public: void ProcessOwnUserKeyChange( SetMessage^ keyChangeMessage, array<byte>^ engineId )
| Exception | Description |
|---|---|
| System.ArgumentException | The exception that is thrown when one of the arguments provided to a method is not valid. |
| System.Exception | Represents errors that occur during application execution. |
private void SetupRequirements() { //USM User Spinlock variable is required and should be incremented each time it is requested. agent1.Variables.Add(agent1.Mib.CreateVariable(NodeName.usmUserSpinLock, "1")); //USM USer Public is used to determine if the key change was successful or not. If the agent1.Variables.Add(agent1.Mib.CreateVariable(NodeName.usmUserPublic, "0")); } private void requestReceived(Dart.Snmp.Agent agentIn, RequestMessage request, object state) { //Likely keychange request. if (request.Variables.Count == 3 && request.Variables[0].GetName() == "1.3.6.1.6.3.15.1.2.1.0 (usmUserSpinLock)" && request is SetMessage) { //NOTE: Place any additional user or permission verification code here as processing this will change //the entity's privacy or authentication key. //Make sure our SNMP entity is authoritative for the user. if (agentIn.Security.AuthoritativeEngine.Users.ContainsKey(request.Security.User.Name)) { User targetUser = agentIn.Security.AuthoritativeEngine.Users[request.Security.User.Name]; try { //Process the change request. targetUser.ProcessOwnUserKeyChange(request as SetMessage, request.Security.EngineId); //Set the USM User Public variable so that the requesting side can verify that the change request //was successful. agentIn.Variables[request.Variables[2].Id].Value = request.Variables[2].Value; } catch(Exception Ex) { //Keychange failed or setting usm user public failed. //Marshal the exception back for handling. agent1.Marshal(Ex); } } } //Create our response and send it. ResponseMessage response = agentIn.CreateResponse(request); agentIn.Send(response, request.Origin); }
Private Sub SetupRequirements() 'USM User Spinlock variable is required and should be incremented each time it is requested. agent1.Variables.Add(agent1.Mib.CreateVariable(NodeName.usmUserSpinLock, "1")) 'USM USer Public is used to determine if the key change was successful or not. agent1.Variables.Add(agent1.Mib.CreateVariable(NodeName.usmUserPublic, "0")) End Sub Private Sub requestReceived(ByVal agentIn As Dart.Snmp.Agent, ByVal request As RequestMessage, ByVal state As Object) 'This is likely a keychange request If request.Variables.Count = 3 AndAlso request.Variables(0).GetName() = "1.3.6.1.6.3.15.1.2.1.0 (usmUserSpinLock)" AndAlso TypeOf request Is SetMessage Then 'NOTE Place anyy additional user Or permission verification code here as processing this will change 'the entity's privacy or authentication key. 'Make sure our SNMP entity is authoritative for the user. If agentIn.Security.AuthoritativeEngine.Users.ContainsKey(request.Security.User.Name) Then Dim targetUser As User = agentIn.Security.AuthoritativeEngine.Users(request.Security.User.Name) Try 'Process the change request. targetUser.ProcessOwnUserKeyChange(TryCast(request, SetMessage), request.Security.EngineId) 'Set the USM User Public variable so that the requesting side can verify that the change request 'was successful. agentIn.Variables(request.Variables(2).Id).Value = request.Variables(2).Value Catch Ex As Exception 'Keychange failed Or setting usm user public failed. 'Marshal the exception back for handling. agent1.Marshal(Ex) End Try End If End If 'Create our response and send it. Dim response As ResponseMessage = agentIn.CreateResponse(request) agentIn.Send(response, request.Origin) End Sub